-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[@types/urijs] Fix unnecessarily strict query params #54650
Conversation
@binury Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through. This is a live comment which I will keep updated. 1 package in this PR
Code ReviewsBecause you edited one package and updated the tests (👏), I can help you merge this PR once someone else signs off on it. You can test the changes of this PR in the Playground. Status
All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 54650,
"author": "binury",
"headCommitOid": "ee7d02a8ec3e4f0b3e32277049bd93e93f94c4b6",
"lastPushDate": "2021-09-05T16:18:12.000Z",
"lastActivityDate": "2021-09-07T18:29:26.000Z",
"mergeOfferDate": "2021-09-06T14:20:27.000Z",
"mergeRequestDate": "2021-09-07T18:29:26.000Z",
"mergeRequestUser": "binury",
"hasMergeConflict": false,
"isFirstContribution": true,
"tooManyFiles": false,
"popularityLevel": "Popular",
"pkgInfo": [
{
"name": "urijs",
"kind": "edit",
"files": [
{
"path": "types/urijs/index.d.ts",
"kind": "definition"
},
{
"path": "types/urijs/test/urijs-dom.test.ts",
"kind": "test"
},
{
"path": "types/urijs/test/urijs-nodejs.test.ts",
"kind": "test"
}
],
"owners": [
"RodneyJT",
"xt0rted",
"petejohanson",
"ljqx",
"teamworkguy2",
"Akuukis",
"marcelltoth",
"XVincentX",
"ahagelstein",
"apepper"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Popular"
}
],
"reviews": [
{
"type": "approved",
"reviewer": "marcelltoth",
"date": "2021-09-06T14:19:50.000Z",
"isMaintainer": false
}
],
"mainBotCommentID": 883670372,
"ciResult": "pass"
} |
🔔 @RodneyJT @xt0rted @petejohanson @ljqx @TeamworkGuy2 @Akuukis @marcelltoth @XVincentX @ahagelstein @apepper — please review this PR in the next few days. Be sure to explicitly select |
For some reason, URI query params were declared as strictly as |
Re-ping @RodneyJT, @xt0rted, @petejohanson, @ljqx, @TeamworkGuy2, @Akuukis, @marcelltoth, @XVincentX, @ahagelstein, @apepper: This PR has been out for over a week, yet I haven't seen any reviews. Could someone please give it some attention? Thanks! |
types/urijs/index.d.ts
Outdated
interface QueryDataMap { | ||
[key: string]: string | null | Array<string | null>; | ||
} | ||
type QueryDataMap = Record<string, any>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is likely less safe than before. any
can take literally anything, including objects, Map
s, and a lot of things we shouldn't allow. What's wrong with taking your list (assuming you double checked it is correct): boolean | number | string | null | undefined | Array<boolean | number | string | null | undefined>
.
Also to be correct we should make it Partial<Record<....>>
because of course it is a partial. (Non-partial Record<string>
s almost never make any sense.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QueryDataMaps can take literally anything including objects, Map
s, and a lot of things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-partial Records almost never make any sense.
These are parameters for a URL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's wrong with taking your list?
<boolean | number | string | null | undefined | Array<boolean | number | string | null | undefined>
The issue that I see is that it would be incomplete, because urijs queries can support any object, even if it seems like it shouldn't. https://github.com/medialize/URI.js/blob/gh-pages/src/URI.js#L782-L811
map = new Map()
map.set('a', 'b')
uri('github.com').addQuery({'map':map}).toString() // => 'github.com?map=%5Bobject+Map%5D'
@binury One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits. Thank you! |
The issue that I see is that it would be incomplete, because urijs queries can support any object, even if it seems like it shouldn't. https://github.com/medialize/URI.js/blob/gh-pages/src/URI.js#L782-L811 map = new Map()
map.set('a', 'b')
uri('github.com').addQuery({'map':map}).toString() // => 'github.com?map=%5Bobject+Map%5D' |
A similar debate has been addressed in the Typescript repo:
This is the function that urijs is using calling to parse queries and its flexibility is why I opted to allow However, maybe following precedent would be the sensible route –in lieu of consensus?– which was to "[represent] the intended use cases". |
@marcelltoth Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point. Actually you convinced me, I'm good with making it any
, but please make it a Partial
(unless you see a reason not to), then I'll approve.
Sorry, I'm not familiar with TS partials— a partial of ? |
Re-ping @RodneyJT, @xt0rted, @petejohanson, @ljqx, @TeamworkGuy2, @Akuukis, @marcelltoth, @XVincentX, @ahagelstein, @apepper: This PR has been out for over a week, yet I haven't seen any reviews. Could someone please give it some attention? Thanks! |
It has been more than two weeks and this PR still has no reviews. I'll bump it to the DT maintainer queue. Thank you for your patience, @binury. (Ping @RodneyJT, @xt0rted, @petejohanson, @ljqx, @TeamworkGuy2, @Akuukis, @marcelltoth, @XVincentX, @ahagelstein, @apepper.) |
I think @marcelltoth was referring to the |
Suggested per #54650
@marcelltoth Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |
@binury: Everything looks good here. I am ready to merge this PR (at ee7d02a) on your behalf whenever you think it's ready. If you'd like that to happen, please post a comment saying:
and I'll merge this PR almost instantly. Thanks for helping out! ❤️ (@RodneyJT, @xt0rted, @petejohanson, @ljqx, @TeamworkGuy2, @Akuukis, @marcelltoth, @XVincentX, @ahagelstein, @apepper: you can do this too.) |
Ready to merge |
I just published |
npm test <package to test>
.changing an existing definition: